package com.dzu.easy;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ZhaoDong
 * @date 2022/8/2 9:42
 * @description leetcode
 * 145. 二叉树的后序遍历
 */
public class Test145 {

    public static List<Integer> postorderTraversal(TreeNode root) {
        List<Integer> list = new ArrayList<>();
        postSearch(root, list);
        return list;
    }

    public static void postSearch(TreeNode root, List<Integer> list) {
        if (root == null) {
            return;
        }
        postSearch(root.left, list);
        postSearch(root.right, list);
        list.add(root.val);
    }
}
